package cn.gong.jizhang.manager;

import java.util.HashMap;
import java.util.Set;

import cn.gong.jizhang.ui.base.BaseAct;


public class ActivityManager {
	private HashMap<Integer, BaseAct> allActivity;
	private int size = 0;
	public static int CURRENT_ACTID;

	private static ActivityManager instance = new ActivityManager();

	private ActivityManager() {
		allActivity = new HashMap<Integer, BaseAct>();
	}

	public static ActivityManager getInstance() {
		return instance;
	}

	public void registerAct(BaseAct baseAct) {
		baseAct.setActID(size);
		addActivity(baseAct);
	}

	public int getSize() {
		return size;
	}

	public BaseAct getActivity(int key) {
		return allActivity.get(key);
	}

	public void removeActivity(BaseAct activity) {
		// 防止actId重复。移除时size不自减
		allActivity.remove(activity.getActID());
	}

	public void addActivity(BaseAct activity) {
		size++;
		allActivity.put(activity.getActID(), activity);
	}

	public Set<Integer> getActivityKeySet() {
		return allActivity.keySet();
	}

}
